package com.rshare.domain.dssw;

import java.io.Serializable;
import java.util.Date;
import org.apache.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectWriter;
import com.rshare.cloudapi.domain.dssw.Dsswdy;
import com.rshare.cloudapi.domain.dssw.Dsswzq;

public class DsswVo implements Serializable {

	private static final long serialVersionUID = 1L;

	static Logger logger = Logger.getLogger(DsswVo.class);

	// 定时事务字段
	private String swId;
	private String swTitle;
	private String swType;
	private String swContent;
	private String swSql;

	// 定时事务周期字段
	private Long zqId;
	private Date zqBeginDate;
	private Date zqEndDate;
	private String zqUnit;
	private Long zqRepeatCount;
	private Long zqInterval;
	private Long zqYear;
	private Long zqMonth;
	private Long zqWeek;
	private Long zqDay;
	private Long zqHour;
	private Long zqMinute;
	private Long zqSecond;
	private String zqNotifier;
	private String zqNotifyMethod;
	private String zqStarted; // 启动/停止

	// 公共信息字段
	private String corpid;
	private String whrid;
	private String whr;

	public DsswVo() {
	}

	public DsswVo(Dsswdy dsswdy, Dsswzq dsswzq) {
		this.swId = dsswdy.getId();
		this.swTitle = dsswdy.getTitle();
		this.swType = dsswdy.getType();
		this.swContent = dsswdy.getContent();
		this.swSql = dsswdy.getSql();

		this.zqId = dsswzq.getId();
		this.zqBeginDate = dsswzq.getBeginDate();
		this.zqEndDate = dsswzq.getEndDate();
		this.zqUnit = dsswzq.getUnit();
		this.zqRepeatCount = dsswzq.getRepeatCount();
		this.zqInterval = dsswzq.getInterval();
		this.zqYear = dsswzq.getYear();
		this.zqMonth = dsswzq.getMonth();
		this.zqWeek = dsswzq.getWeek();
		this.zqDay = dsswzq.getDay();
		this.zqHour = dsswzq.getHour();
		this.zqMinute = dsswzq.getMinute();
		this.zqSecond = dsswzq.getSecond();
		this.zqNotifier = dsswzq.getNotifier();
		this.zqNotifyMethod = dsswzq.getNotifyMethod();
		this.zqStarted = dsswzq.getStarted();

		this.corpid = dsswzq.getCorpid();
		this.whrid = dsswzq.getWhrid();
		this.whr = dsswzq.getWhr();
	}

	public String toJson() {
		ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
		try {
			String json = ow.writeValueAsString(this);
			return json;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static DsswVo fromJson(String str) {
		ObjectMapper mapper = new ObjectMapper();
		try {
			DsswVo dv = mapper.readValue(str, DsswVo.class);
			return dv;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public String getSwId() {
		return swId;
	}

	public void setSwId(String swid) {
		this.swId = swid;
	}

	public String getSwTitle() {
		return swTitle;
	}

	public void setSwTitle(String swTitle) {
		this.swTitle = swTitle;
	}

	public String getSwType() {
		return swType;
	}

	public void setSwType(String swType) {
		this.swType = swType;
	}

	public String getSwContent() {
		return swContent;
	}

	public void setSwContent(String swContent) {
		this.swContent = swContent;
	}

	public String getSwSql() {
		return swSql;
	}

	public void setSwSql(String swSql) {
		this.swSql = swSql;
	}

	public Long getZqId() {
		return zqId;
	}

	public void setZqId(Long zqId) {
		this.zqId = zqId;
	}

	public Date getZqBeginDate() {
		return zqBeginDate;
	}

	public void setZqBeginDate(Date zqBeginDate) {
		this.zqBeginDate = zqBeginDate;
	}

	public Date getZqEndDate() {
		return zqEndDate;
	}

	public void setZqEndDate(Date zqEndDate) {
		this.zqEndDate = zqEndDate;
	}

	public String getZqUnit() {
		return zqUnit;
	}

	public void setZqUnit(String zqUnit) {
		this.zqUnit = zqUnit;
	}

	public Long getZqInterval() {
		return zqInterval;
	}

	public void setZqInterval(Long zqInterval) {
		this.zqInterval = zqInterval;
	}

	public Long getZqYear() {
		return zqYear;
	}

	public void setZqYear(Long zqYear) {
		this.zqYear = zqYear;
	}

	public Long getZqMonth() {
		return zqMonth;
	}

	public void setZqMonth(Long zqMonth) {
		this.zqMonth = zqMonth;
	}

	public Long getZqWeek() {
		return zqWeek;
	}

	public void setZqWeek(Long zqWeek) {
		this.zqWeek = zqWeek;
	}

	public Long getZqDay() {
		return zqDay;
	}

	public void setZqDay(Long zqDay) {
		this.zqDay = zqDay;
	}

	public Long getZqHour() {
		return zqHour;
	}

	public void setZqHour(Long zqHour) {
		this.zqHour = zqHour;
	}

	public Long getZqMinute() {
		return zqMinute;
	}

	public void setZqMinute(Long zqMinute) {
		this.zqMinute = zqMinute;
	}

	public Long getZqSecond() {
		return zqSecond;
	}

	public void setZqSecond(Long zqSecond) {
		this.zqSecond = zqSecond;
	}

	public String getZqNotifier() {
		return zqNotifier;
	}

	public void setZqNotifier(String zqNotifier) {
		this.zqNotifier = zqNotifier;
	}

	public String getZqNotifyMethod() {
		return zqNotifyMethod;
	}

	public void setZqNotifyMethod(String zqNotifyMethod) {
		this.zqNotifyMethod = zqNotifyMethod;
	}

	public String getZqStarted() {
		return zqStarted;
	}

	public void setZqStarted(String started) {
		this.zqStarted = started;
	}

	public String getWhrid() {
		return whrid;
	}

	public void setWhrid(String whrid) {
		this.whrid = whrid;
	}

	public String getWhr() {
		return whr;
	}

	public void setWhr(String whr) {
		this.whr = whr;
	}

	public String getCorpid() {
		return corpid;
	}

	public void setCorpid(String corpid) {
		this.corpid = corpid;
	}

	public Long getZqRepeatCount() {
		return zqRepeatCount;
	}

	public void setZqRepeatCount(Long zqRepeatCount) {
		this.zqRepeatCount = zqRepeatCount;
	}

}
